package ls.ch03.demo.demo8;

import net.sf.cglib.proxy.InvocationHandler;

import java.lang.reflect.Method;

/**
 * @author ls
 * @Date 创建时间:2022/4/8 13:32
 * 描述:
 */

public class IntermediaryInvocationHandler implements InvocationHandler {
    private Object target;
    public void  setTarget(Object target){
        this.target=target;
    }
    @Override
    public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
        before();
        Object feedback = method.invoke(target,args);
        after();
        return "看房记录：买房反馈“"+feedback+"”";
    }

    private void after() {
        System.out.println("前期准备。");
        System.out.println("查找放源。");
        System.out.println("和卖家沟通时间。");
    }

    private void before() {
        System.out.println("后期跟踪");
        System.out.println("和买家沟通意见。");
    }
}
